﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace System.Web.Mvc.Html.jTable
{
    public class jTableOptions
    {
        public jTableOptions()
        {
            Fields = new List<OptionField>();
            General = new OptionGeneral();
            Action = new OptionAction();
        }

        public OptionGeneral General { get; set; }
        public OptionAction Action { get; set; }
        public List<OptionField> Fields { get; set; }
    }

    public class OptionGeneral
    {
        public OptionGeneral()
        {
            PagingEnabled = false;
            EditButton = false;
            DeleteButton = false;
            MultiSelect = false;
            CheckBoxColumn = false;
            PageSize = 10;
        }

        public Boolean PagingEnabled { get; set; }
        public Int32 PageSize { get; set; }
        public String DefaultSortingColumnName { get; set; }
        public SortingOrder DefaultSortingOrder { get; set; }
        public Boolean EditButton { get; set; }
        public Boolean DeleteButton { get; set; }
        public Boolean CheckBoxColumn { get; set; }
        public Boolean MultiSelect { get; set; }
        public String ContainerHtmlElementID { get; set; }
    }

    public class OptionAction
    {
        public String ListUrl { get; set; }
    }

    public class OptionField
    {
        public OptionField()
        {
            Caption = String.Empty;
            DataType = FieldDataType.None;
            Format = String.Empty;
            SortingEnabled = false;
            DisplayFunction = String.Empty;
            Width = String.Empty;
        }
        public Boolean Key { get; set; }
        public String Name { get; set; }
        public String Caption { get; set; }
        public FieldDataType DataType { get; set; }
        public String Format { get; set; }
        public Boolean SortingEnabled { get; set; }
        public String DisplayFunction { get; set; }
        public String Width { get; set; }
    }

    public enum SortingOrder
    {
        ASC,
        DESC
    }

    public enum FieldDataType
    {
        None,
        Date,
        DateTime,
        String,
        Integer,
        Float
    }
}
